#!/bin/sh

# Starts, stops, and restarts Apache Solr.
#
# chkconfig: 35 92 08
# description: Starts and stops Apache Solr

SOLR_DIR="/usr/local/solr/solr-7.3.1"
SOLR_COMMAND="bin/solr"
SOLR_ARGS="-m 1g"
SOLR_USER=solr

case $1 in
    start)
        echo "Starting Solr"
        # Increase file descriptor limit:
        ulimit -n 65000
        cd $SOLR_DIR
        sudo -u $SOLR_USER $SOLR_COMMAND start $SOLR_ARGS
        ;;
    stop)
        echo "Stopping Solr"
        cd $SOLR_DIR
        sudo -u $SOLR_USER $SOLR_COMMAND stop $SOLR_ARGS
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
esac

